package com.aier.school.entity.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

import net.eicp.ghostboy.futil.StringUtil;

import org.springframework.jdbc.core.RowMapper;

import com.aier.school.entity.SchoolTeacherCharisma;

public class SchoolTeacherCharismaRowMapper implements RowMapper<SchoolTeacherCharisma> {
    @SuppressWarnings("unused")
    private int type;

    public SchoolTeacherCharismaRowMapper() {
    }

    public SchoolTeacherCharismaRowMapper(int type) {
        this.type = type;
    }

    @Override
    public SchoolTeacherCharisma mapRow(ResultSet rs, int rowNum) throws SQLException {
        return parseSchoolInfo(new SchoolTeacherCharisma(), rs);
    }

    public static SchoolTeacherCharisma parseSchoolInfo(SchoolTeacherCharisma si, ResultSet rs) throws SQLException {
        return parseSchoolInfo(si, rs, null);
    }

    public static SchoolTeacherCharisma parseSchoolInfo(SchoolTeacherCharisma si, ResultSet rs, String su)
        throws SQLException {

        if (StringUtil.isStringNull(su)) {
            su = "";
        } else {
            su += ".";
        }
        try {
            si.setStcid(rs.getLong(su+"stcid"));
        } catch (SQLException e) {
            si.setStcid(null);
        }
        try {
            si.setSid(rs.getInt(su+"sid"));
        } catch (SQLException e) {
            si.setSid(null);
        }
        try {
            si.setName(rs.getString(su+"name"));
        } catch (SQLException e) {
            si.setName(null);
        }
        try {
            si.setImg(rs.getString(su+"img"));
        } catch (SQLException e) {
            si.setImg(null);
        }
        try {
            si.setDesinfo(rs.getString(su+"desinfo"));
        } catch (SQLException e) {
            si.setDesinfo(null);
        }
        try {
            si.setCtime(rs.getTimestamp(su+"ctime"));
        } catch (SQLException e) {
            si.setCtime(null);
        }
        return si;
    }

    public static Map<String, Object> getPar(Map<String, Object> par, SchoolTeacherCharisma si) {
        par.put("stcid", si.getStcid());
        par.put("sid", si.getSid());
        par.put("name",si.getName());
        par.put("img", si.getImg());
        par.put("desinfo", si.getDesinfo());
        par.put("ctime", si.getCtime());
        return par;
    }

}
